<!doctype html>



  


<html class="theme-next muse use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Microsoft YaHei:300,300italic,400,400italic,700,700italic|consolas:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="js," />








  <link rel="shortcut icon" type="image/x-icon" href="http://ofy7k3v4s.bkt.clouddn.com/mylogo.png?v=5.0.2" />






<meta name="description" content="ECMAScript &amp;#x8BED;&amp;#x6CD5;&amp;#x5B9A;&amp;#x4E49;&amp;#x7684;&amp;#x8BED;&amp;#x53E5;&amp;#x901A;&amp;#x5E38;&amp;#x4F7F;&amp;#x7528;&amp;#x4E00;&amp;#x4E2A;&amp;#x6216;&amp;#x591A;&amp;#x4E2A;&amp;#x5173;&amp;#x952E;&amp;#x5B57;&amp;#x6765;&amp;#x5B8C;&amp;#x6210;&amp;#x7ED9;&amp;#x5B">
<meta property="og:type" content="article">
<meta property="og:title" content="js语句">
<meta property="og:url" content="https://hongqinma.github.io/2014/04/06/05-js-语句/index.html">
<meta property="og:site_name" content="HongqinMa' Blog">
<meta property="og:description" content="ECMAScript &amp;#x8BED;&amp;#x6CD5;&amp;#x5B9A;&amp;#x4E49;&amp;#x7684;&amp;#x8BED;&amp;#x53E5;&amp;#x901A;&amp;#x5E38;&amp;#x4F7F;&amp;#x7528;&amp;#x4E00;&amp;#x4E2A;&amp;#x6216;&amp;#x591A;&amp;#x4E2A;&amp;#x5173;&amp;#x952E;&amp;#x5B57;&amp;#x6765;&amp;#x5B8C;&amp;#x6210;&amp;#x7ED9;&amp;#x5B">
<meta property="og:updated_time" content="2016-11-21T04:00:39.566Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="js语句">
<meta name="twitter:description" content="ECMAScript &amp;#x8BED;&amp;#x6CD5;&amp;#x5B9A;&amp;#x4E49;&amp;#x7684;&amp;#x8BED;&amp;#x53E5;&amp;#x901A;&amp;#x5E38;&amp;#x4F7F;&amp;#x7528;&amp;#x4E00;&amp;#x4E2A;&amp;#x6216;&amp;#x591A;&amp;#x4E2A;&amp;#x5173;&amp;#x952E;&amp;#x5B57;&amp;#x6765;&amp;#x5B8C;&amp;#x6210;&amp;#x7ED9;&amp;#x5B">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '6347850919329138000',
      author: 'Hiraku'
    }
  };
</script>




  <link rel="canonical" href="https://hongqinma.github.io/2014/04/06/05-js-语句/"/>


  <title> js语句 | HongqinMa' Blog </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="en">

  



  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?10010323";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  
    <div class="site-meta-headline">
      <a>
        <img class="custom-logo-image" src="http://ofy7k3v4s.bkt.clouddn.com/photo.jpg"
             alt="HongqinMa' Blog"/>
      </a>
    </div>
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">HongqinMa' Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Spell at all costs， to rush you in the future。</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                js语句
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2014-04-06T22:29:25+08:00" content="2014-04-06">
              2014-04-06
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/JavaScript/" itemprop="url" rel="index">
                    <span itemprop="name">JavaScript</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2014/04/06/05-js-语句/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2014/04/06/05-js-语句/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          

          
              &nbsp; | &nbsp;
              <span class="page-pv"><i class="fa fa-file-o"></i>
              <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
              </span>
          

          
            <span id="busuanzi_container_page_pv">  <span id="busuanzi_value_page_pv"></span> Views</span>
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>ECMAScript &#x8BED;&#x6CD5;&#x5B9A;&#x4E49;&#x7684;&#x8BED;&#x53E5;&#x901A;&#x5E38;&#x4F7F;&#x7528;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x5173;&#x952E;&#x5B57;&#x6765;&#x5B8C;&#x6210;&#x7ED9;&#x5B9A;&#x7684;&#x4EFB;&#x52A1;&#x3002;</p>
<h2 id="&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x7ED3;&#x6784;-if-if&#x2026;else-if&#x2026;else-&#x5D4C;&#x5957;"><a href="#&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x7ED3;&#x6784;-if-if&#x2026;else-if&#x2026;else-&#x5D4C;&#x5957;" class="headerlink" title="&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x7ED3;&#x6784; if/ if&#x2026;else/ if&#x2026;else &#x5D4C;&#x5957;"></a>&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x7ED3;&#x6784; if/ if&#x2026;else/ if&#x2026;else &#x5D4C;&#x5957;</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">if</span>(&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;){</div><div class="line">  <span class="comment">// &#x5982;&#x679C;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x4E3A;true&#xFF0C;&#x6267;&#x884C;&#x8BE5;&#x5904;&#x4EE3;&#x7801;</span></div><div class="line">}<span class="keyword">else</span>{</div><div class="line">  <span class="comment">// &#x5982;&#x679C;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x4E3A;false,&#x6267;&#x884C;&#x8BE5;&#x5904;&#x4EE3;&#x7801;</span></div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x7684;&#x5D4C;&#x5957;</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">if(&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#xFF09;{</div><div class="line">  //&#x5982;&#x679C;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x7ED3;&#x679C;&#x4E3A;true,&#x6267;&#x884C;&#x8BE5;&#x8BED;&#x53E5;&#xFF0C;&#x4E0B;&#x8FB9;&#x8BED;&#x53E5;&#x4E0D;&#x6267;&#x884C;&#x3002;</div><div class="line">}else if(&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;){</div><div class="line">  // &#x5982;&#x679C;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x7ED3;&#x679C;&#x4E3A;true,&#x6267;&#x884C;&#x8BE5;&#x8BED;&#x53E5;&#xFF0C;&#x4E0B;&#x8FB9;&#x8BED;&#x53E5;&#x4E0D;&#x6267;&#x884C;&#x3002;</div><div class="line">}else if(&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;){</div><div class="line">  // &#x5982;&#x679C;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x7ED3;&#x679C;&#x4E3A;true,&#x6267;&#x884C;&#x8BE5;&#x8BED;&#x53E5;&#xFF0C;&#x4E0B;&#x8FB9;&#x8BED;&#x53E5;&#x4E0D;&#x6267;&#x884C;&#x3002;</div><div class="line">}else {</div><div class="line">  // &#x5982;&#x679C;&#x4EE5;&#x4E0A;&#x8BED;&#x53E5;&#x90FD;&#x4E3A;false,&#x6267;&#x884C;&#x8BE5;&#x8BED;&#x53E5;&#x3002;</div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="Switch&#x8BED;&#x53E5;"><a href="#Switch&#x8BED;&#x53E5;" class="headerlink" title="Switch&#x8BED;&#x53E5;"></a>Switch&#x8BED;&#x53E5;</h2><p>&#x5199;&#x6CD5;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> mon=prompt(<span class="string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x6708;&#x4EFD;&quot;</span>);</div><div class="line"><span class="keyword">switch</span>(mon){</div><div class="line">  <span class="keyword">case</span> <span class="string">&quot;3&quot;</span>: <span class="keyword">case</span> <span class="string">&quot;4&quot;</span>:  <span class="keyword">case</span> <span class="string">&quot;5&quot;</span>:</div><div class="line">  alert(<span class="string">&quot;&#x6625;&#x5B63;&quot;</span>);</div><div class="line">  <span class="keyword">break</span>;</div><div class="line">  <span class="keyword">case</span> <span class="string">&quot;6&quot;</span>: <span class="keyword">case</span> <span class="string">&quot;7&quot;</span>:  <span class="keyword">case</span> <span class="string">&quot;8&quot;</span>:</div><div class="line">  alert(<span class="string">&quot;&#x590F;&#x5B63;&quot;</span>);</div><div class="line">  <span class="keyword">break</span>;</div><div class="line">  <span class="keyword">case</span> <span class="string">&quot;9&quot;</span>: <span class="keyword">case</span> <span class="string">&quot;10&quot;</span>:  <span class="keyword">case</span> <span class="string">&quot;11&quot;</span>:</div><div class="line">  alert(<span class="string">&quot;&#x79CB;&#x5B63;&quot;</span>);</div><div class="line">  <span class="keyword">break</span>;</div><div class="line">  <span class="keyword">case</span> <span class="string">&quot;12&quot;</span>: <span class="keyword">case</span> <span class="string">&quot;1&quot;</span>:  <span class="keyword">case</span> <span class="string">&quot;2&quot;</span>:</div><div class="line">  alert(<span class="string">&quot;&#x51AC;&#x5B63;&quot;</span>);</div><div class="line">  <span class="keyword">break</span>;</div><div class="line">  <span class="keyword">default</span>:</div><div class="line">  alert(<span class="string">&quot;&#x8BF7;&#x8F93;&#x5165;&#x6B63;&#x786E;&#x6708;&#x4EFD;&quot;</span>);</div><div class="line">  <span class="keyword">break</span>;</div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x6CE8;&#x610F;:switch&#x540E;&#x8FB9;&#x7684;&#x53D8;&#x91CF;&#x548C;case&#x540E;&#x8FB9;&#x503C;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5FC5;&#x987B;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#x3002;</p>
<hr>
<h2 id="While&#x5FAA;&#x73AF;&#x8BED;&#x53E5;"><a href="#While&#x5FAA;&#x73AF;&#x8BED;&#x53E5;" class="headerlink" title="While&#x5FAA;&#x73AF;&#x8BED;&#x53E5;"></a>While&#x5FAA;&#x73AF;&#x8BED;&#x53E5;</h2><p>&#x8BED;&#x6CD5;:</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> n1;</div><div class="line">While(&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;){</div><div class="line">  <span class="comment">// &#x5FAA;&#x73AF;&#x8BED;&#x53E5;</span></div><div class="line">}</div></pre></td></tr></table></figure>
<p>&#x5982;&#x679C;while&#x540E;&#x8FB9;&#x7684;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x4E3A;true,&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x4E00;&#x76F4;&#x6267;&#x884C;&#xFF0C;&#x76F4;&#x5230;while&#x540E;&#x8FB9;&#x7684;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x4E3A;false, &#x5FAA;&#x73AF;&#x7EC8;&#x6B62;&#xFF08;&#x8DF3;&#x51FA;&#x5FAA;&#x73AF;&#xFF09;,&#x4F7F;&#x7528;while&#x8BED;&#x53E5;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x9700;&#x5728;&#x5916;&#x8FB9;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x3002;</p>
<h2 id="Do-while-&#x8BED;&#x53E5;"><a href="#Do-while-&#x8BED;&#x53E5;" class="headerlink" title="Do while &#x8BED;&#x53E5;"></a>Do while &#x8BED;&#x53E5;</h2><p>&#x8BED;&#x6CD5;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">do</span>{</div><div class="line">  <span class="comment">// &#x5FAA;&#x73AF;&#x8BED;&#x53E5;</span></div><div class="line">}<span class="keyword">while</span>(&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;)</div></pre></td></tr></table></figure>
<p>&#x5148;&#x6267;&#x884C;do&#x91CC;&#x5FAA;&#x73AF;&#x4EE3;&#x7801;&#xFF0C;&#x518D;&#x548C;while&#x540E;&#x8FB9;&#x7684;&#x6761;&#x4EF6;&#x8868;&#x8FBE;&#x5F0F;&#x8FDB;&#x884C;&#x5224;&#x65AD;&#xFF0C;&#x5982;&#x679C;&#x7ED3;&#x679C;&#x4E3A;true,&#x7EE7;&#x7EED;&#x6267;&#x884C;do&#x91CC;&#x7684;&#x5FAA;&#x73AF;&#xFF0C;&#x7ED3;&#x679C;&#x4E3A;false&#xFF0C;&#x5FAA;&#x73AF;&#x7EC8;&#x6B62;&#x3002;&#x6BD4;while&#x591A;&#x6267;&#x884C;&#x4E00;&#x6B21;&#x5FAA;&#x73AF;&#x3002;</p>
<p><strong>while&#x8BED;&#x53E5; &#x5148;&#x5224;&#x65AD;&#x540E;&#x6267;&#x884C;do while &#x8BED;&#x53E5; &#x5148;&#x6267;&#x884C;&#x540E;&#x5224;&#x65AD;</strong></p>
<h2 id="for&#x5FAA;&#x73AF;"><a href="#for&#x5FAA;&#x73AF;" class="headerlink" title="for&#x5FAA;&#x73AF;"></a>for&#x5FAA;&#x73AF;</h2><p>&#x8BED;&#x6CD5;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">for</span>(<span class="keyword">var</span> i=<span class="number">1</span>; i&lt;=<span class="number">100</span>; i++){</div><div class="line">  <span class="comment">//&#x5FAA;&#x73AF;&#x4EE3;&#x7801;</span></div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="break&#x8BED;&#x53E5;"><a href="#break&#x8BED;&#x53E5;" class="headerlink" title="break&#x8BED;&#x53E5;"></a>break&#x8BED;&#x53E5;</h2><p>&#x5355;&#x72EC;&#x4F7F;&#x7528; break &#x8BED;&#x53E5;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x7ACB;&#x5373;&#x9000;&#x51FA;&#x6700;&#x5185;&#x5C42;&#x7684;&#x5FAA;&#x73AF;&#x6216; switch &#x8BED;&#x53E5;&#x3002;</p>
<p>&#x8BED;&#x6CD5;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">while</span>(){</div><div class="line">  <span class="comment">// &#x5FAA;&#x73AF;&#x8BED;&#x53E5;</span></div><div class="line">  <span class="keyword">break</span>;</div><div class="line">}</div></pre></td></tr></table></figure>
<p>Break&#x662F;&#x8DF3;&#x51FA;&#x5F53;&#x524D;&#x5FAA;&#x73AF;&#x4F53;&#xFF1B;</p>
<h2 id="continue&#x8BED;&#x53E5;"><a href="#continue&#x8BED;&#x53E5;" class="headerlink" title="continue&#x8BED;&#x53E5;"></a>continue&#x8BED;&#x53E5;</h2><p>&#x8DF3;&#x51FA;&#x5FAA;&#x73AF;&#x4E00;&#x6B21;&#x3002;&#x540E;&#x8FB9;&#x7684;&#x4EE3;&#x7801;&#x4E0D;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x3002;</p>
<h3 id="break-&#x548C;-continue-&#x7684;&#x533A;&#x522B;"><a href="#break-&#x548C;-continue-&#x7684;&#x533A;&#x522B;" class="headerlink" title="break &#x548C; continue &#x7684;&#x533A;&#x522B;"></a>break &#x548C; continue &#x7684;&#x533A;&#x522B;</h3><ul>
<li>break&#x8DF3;&#x51FA;&#x5F53;&#x524D;&#x5FAA;&#x73AF;&#xFF0C;&#x6267;&#x884C;&#x5FAA;&#x73AF;&#x540E;&#x7684;&#x8BED;&#x53E5;</li>
<li>continue&#x8DF3;&#x51FA;&#x5F53;&#x524D;&#x5FAA;&#x73AF;&#xFF0C;&#x7EE7;&#x7EED;&#x6267;&#x884C;&#x5FAA;&#x73AF;</li>
</ul>
<h2 id="for-in-&#x5C5E;&#x6027;&#x679A;&#x4E3E;&#x8BED;&#x53E5;"><a href="#for-in-&#x5C5E;&#x6027;&#x679A;&#x4E3E;&#x8BED;&#x53E5;" class="headerlink" title="for-in &#x5C5E;&#x6027;&#x679A;&#x4E3E;&#x8BED;&#x53E5;"></a>for-in &#x5C5E;&#x6027;&#x679A;&#x4E3E;&#x8BED;&#x53E5;</h2><p><code>for-in</code> &#x8BED;&#x53E5;&#x7528;&#x6765;&#x679A;&#x4E3E;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">for</span>(variable <span class="keyword">in</span> object){</div><div class="line">  <span class="comment">// &#x4EE3;&#x7801;&#x6BB5;</span></div><div class="line">}</div></pre></td></tr></table></figure>
<p>variable &#x662F;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#x540D;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x4E00;&#x4E2A;&#x53EF;&#x4EE5;&#x4EA7;&#x751F;&#x5DE6;&#x503C;&#x8868;&#x8FBE;&#x5F0F;&#x6216;&#x8005;&#x4E00;&#x4E2A;&#x901A;&#x8FC7; var &#x8BED;&#x53E5;&#x58F0;&#x660E;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x6BCF;&#x6B21;&#x5FAA;&#x73AF;&#x90FD;&#x4F1A;&#x8BA1;&#x7B97; variable &#x8FD9;&#x4E2A;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x6BCF;&#x6B21;&#x5FAA;&#x73AF;&#x5B83;&#x7684;&#x503C;&#x53EF;&#x80FD;&#x4E0D;&#x540C;&#x3002;for/in &#x5FAA;&#x73AF;&#x5E76;&#x4E0D;&#x4F1A;&#x904D;&#x5386;&#x5BF9;&#x8C61;&#x7684;&#x6240;&#x6709;&#x5C5E;&#x6027;&#xFF0C;&#x53EA;&#x6709;&#x201D;&#x53EF;&#x679A;&#x4E3E;&#x201D;&#x7684;&#x5C5E;&#x6027;&#x624D;&#x4F1A;&#x904D;&#x5386;&#x5230;&#x3002;&#x5185;&#x7F6E;&#x5BF9;&#x8C61;&#x7684;&#x65B9;&#x6CD5;&#x5C31;&#x662F;&#x4E0D;&#x53EF;&#x679A;&#x4E3E;&#x7684;</p>
<h2 id="label-&#xFF08;&#x6807;&#x7B7E;&#xFF09;&#x8BED;&#x53E5;"><a href="#label-&#xFF08;&#x6807;&#x7B7E;&#xFF09;&#x8BED;&#x53E5;" class="headerlink" title="label &#xFF08;&#x6807;&#x7B7E;&#xFF09;&#x8BED;&#x53E5;"></a>label &#xFF08;&#x6807;&#x7B7E;&#xFF09;&#x8BED;&#x53E5;</h2><p>label &#x8BED;&#x53E5;&#x53EF;&#x4EE5;&#x5728;&#x4EE3;&#x7801;&#x4E2D;&#x6DFB;&#x52A0;&#x6807;&#x7B7E;&#xFF0C;&#x4EE5;&#x4FBF;&#x5C06;&#x6765;&#x4F7F;&#x7528;&#x3002;&#x901A;&#x8FC7;&#x7ED9;&#x8BED;&#x53E5;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x5728;&#x7A0B;&#x5E8F;&#x7684;&#x4EFB;&#x4F55;&#x5730;&#x65B9;&#x901A;&#x8FC7;&#x6807;&#x7B7E;&#x540D;&#x5F15;&#x7528;&#x8FD9;&#x6761;&#x8BED;&#x53E5;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">start: <span class="keyword">for</span>(<span class="keyword">var</span> i = <span class="number">0</span>; i &lt; count; i++){</div><div class="line">  <span class="built_in">console</span>.log(i);</div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="with-&#x8BED;&#x53E5;"><a href="#with-&#x8BED;&#x53E5;" class="headerlink" title="with &#x8BED;&#x53E5;"></a>with &#x8BED;&#x53E5;</h2><p>with &#x8BED;&#x53E5;&#x7684;&#x4F5C;&#x7528;&#x662F;&#x5C06;&#x4F5C;&#x7528;&#x57DF;&#x8BBE;&#x7F6E;&#x5230;&#x4E00;&#x4E2A;&#x7279;&#x5B9A;&#x7684;&#x5BF9;&#x8C61;&#x4E2D;&#x3002;&#x5982;&#xFF1A;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> qs = location.search.substring();</div><div class="line"><span class="keyword">var</span> hostName = location.hostname();</div><div class="line"><span class="keyword">var</span> utl = location.href();</div><div class="line"></div><div class="line"><span class="comment">// &#x4EE5;&#x4E0A;&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x5199;&#x6210;&#x4E0B;&#x9762;&#x7684;&#x65B9;&#x5F0F;, &#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#x4E0D;&#x5141;&#x8BB8;&#x4F7F;&#x7528; with</span></div><div class="line"><span class="keyword">with</span>(location){</div><div class="line">  <span class="keyword">var</span> qs = search.substring();</div><div class="line">  <span class="keyword">var</span> hostName = hostname();</div><div class="line">  <span class="keyword">var</span> utl = href();</div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="return-&#x8BED;&#x53E5;"><a href="#return-&#x8BED;&#x53E5;" class="headerlink" title="return &#x8BED;&#x53E5;"></a>return &#x8BED;&#x53E5;</h2><p>&#x51FD;&#x6570;&#x662F;&#x4E00;&#x79CD;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x8868;&#x8FBE;&#x5F0F;&#x90FD;&#x6709;&#x503C;&#x3002;&#x51FD;&#x6570;&#x4E2D;&#x56FD;&#x7684; return &#x8BED;&#x53E5;&#x65E2;&#x662F;&#x6307;&#x5B9A;&#x51FD;&#x6570;&#x8C03;&#x7528;&#x540E;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x3002;&#x56E0;&#x6B64;&#xFF0C;return &#x8BED;&#x53E5;&#x53EA;&#x80FD;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x5185;&#x90E8;&#x51FA;&#x73B0;&#xFF0C;&#x800C;&#x4E14; return &#x8BED;&#x53E5;&#x7ECF;&#x5E38;&#x4F5C;&#x4E3A;&#x51FD;&#x6570;&#x7684;&#x6700;&#x540E;&#x4E00;&#x6761;&#x8BED;&#x53E5;&#x51FA;&#x73B0;&#xFF0C;&#x4F46;&#x5E76;&#x4E0D;&#x662F;&#x8BF4;&#x4E00;&#x5B9A;&#x8981;&#x653E;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x7684;&#x6700;&#x540E;&#xFF0C;&#x5373;&#x4F7F;&#x5728;&#x6267;&#x884C; return &#x8BED;&#x53E5;&#x7684;&#x65F6;&#x5019;&#x8FD8;&#x6709;&#x5F88;&#x591A;&#x540E;&#x7EED;&#x4EE3;&#x7801;&#x6CA1;&#x6709;&#x6267;&#x884C;&#xFF0C;&#x8FD9;&#x662F;&#x51FD;&#x6570;&#x4E5F;&#x8FD8;&#x4F1A;&#x8FD4;&#x56DE;&#x8C03;&#x7528;&#x7A0B;&#x5E8F;&#x3002;</p>
<h2 id="throw-&#x8BED;&#x53E5;"><a href="#throw-&#x8BED;&#x53E5;" class="headerlink" title="throw &#x8BED;&#x53E5;"></a>throw &#x8BED;&#x53E5;</h2><p>&#x5F02;&#x5E38;&#x662F;&#x6307;&#x7A0B;&#x5E8F;&#x5728;&#x7A0B;&#x5E8F;&#x5728;&#x8FD0;&#x884C;&#x65F6;&#x53D1;&#x751F;&#x7684;&#x5F02;&#x5E38;&#x60C5;&#x51B5;&#x6216;&#x9519;&#x8BEF;&#x65F6;&#x4EA7;&#x751F;&#x7684;&#x4E00;&#x4E2A;&#x4FE1;&#x53F7;&#x3002;&#x5728; JavaScript &#x4E2D;&#xFF0C;&#x5F53;&#x4EA7;&#x751F;&#x8FD0;&#x884C;&#x65F6;&#x9519;&#x8BEF;&#x6216;&#x8005;&#x7A0B;&#x5E8F;&#x4F7F;&#x7528; throw &#x8BED;&#x53E5;&#x65F6;&#x5C31;&#x4F1A;&#x663E;&#x5F0F;&#x7684;&#x629B;&#x51FA;&#x5F02;&#x5E38;&#x3002;</p>
<h2 id="try-catch-finally-&#x8BED;&#x53E5;"><a href="#try-catch-finally-&#x8BED;&#x53E5;" class="headerlink" title="try/catch/finally &#x8BED;&#x53E5;"></a>try/catch/finally &#x8BED;&#x53E5;</h2><p>try/catch/finally &#x662F; JavaScript &#x7684;&#x5F02;&#x5E38;&#x5904;&#x7406;&#x673A;&#x5236;&#x3002;&#x5176;&#x4E2D; try &#x4ECE;&#x53E5;&#x4E2D;&#x5B9A;&#x4E49;&#x4E86;&#x9700;&#x8981;&#x5904;&#x7406;&#x7684;&#x5F02;&#x5E38;&#x6240;&#x5728;&#x4EE3;&#x7801;&#x5757;&#xFF0C;catch &#x4ECE;&#x53E5;&#x8DDF;&#x5728; try &#x540E;&#xFF0C;&#x5F53; try &#x5757;&#x5185;&#x53D1;&#x751F;&#x4E86;&#x5F02;&#x5E38;&#x65F6;&#xFF0C;&#x8C03;&#x7528; catch &#x5185;&#x7684;&#x4EE3;&#x7801;&#x903B;&#x8F91;&#x3002;catch &#x4ECE;&#x53E5;&#x540E;&#x8DDF;&#x968F; finally &#x5757;&#xFF0C;&#x540E;&#x8005;&#x4E2D;&#x56FD;&#x653E;&#x7F6E;&#x6E05;&#x7406;&#x4EE3;&#x7801;&#xFF0C;&#x4E0D;&#x7BA1;&#x662F; try &#x5757;&#x4E2D;&#x662F;&#x5426;&#x4EA7;&#x751F;&#x5F02;&#x5E38;&#xFF0C;finally &#x5757;&#x5185;&#x7684;&#x903B;&#x8F91;&#x603B;&#x662F;&#x4F1A;&#x6267;&#x884C;&#x3002;</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">try</span> {</div><div class="line">  <span class="comment">// &#x9700;&#x8981;&#x6355;&#x83B7;&#x5F02;&#x5E38;&#x7684;&#x4EE3;&#x7801;&#x5757;</span></div><div class="line">} <span class="keyword">catch</span>(e) {</div><div class="line">  <span class="comment">// try &#x4EE3;&#x7801;&#x5757;&#x629B;&#x51FA;&#x5F02;&#x5E38;&#x624D;&#x4F1A;&#x6267;&#x884C;&#x6B64;&#x4EE3;&#x7801;&#x5757;&#x4E2D;&#x7684;&#x903B;&#x8F91;</span></div><div class="line">  <span class="comment">// &#x8FD8;&#x53EF;&#x4EE5;&#x901A;&#x8FC7; throw &#x8BED;&#x53E5;&#x6765;&#x518D;&#x6B21;&#x629B;&#x51FA;&#x5F02;&#x5E38;</span></div><div class="line">} <span class="keyword">finally</span> {</div><div class="line">  <span class="comment">// &#x4E0D;&#x7BA1;&#x5F02;&#x5E38;&#x6709;&#x6CA1;&#x6709;&#x53D1;&#x751F;&#xFF0C;&#x8FD9;&#x4E2A;&#x4EE3;&#x7801;&#x5757;&#x4E2D;&#x7684;&#x903B;&#x8F91;&#x90FD;&#x4F1A;&#x6267;&#x884C;</span></div><div class="line">}</div></pre></td></tr></table></figure>
<h2 id="&#x5176;&#x5B83;&#x8BED;&#x53E5;"><a href="#&#x5176;&#x5B83;&#x8BED;&#x53E5;" class="headerlink" title="&#x5176;&#x5B83;&#x8BED;&#x53E5;"></a>&#x5176;&#x5B83;&#x8BED;&#x53E5;</h2><h3 id="debugger-&#x8BED;&#x53E5;"><a href="#debugger-&#x8BED;&#x53E5;" class="headerlink" title="debugger &#x8BED;&#x53E5;"></a>debugger &#x8BED;&#x53E5;</h3><h3 id="&#x201C;use-strict&#x201D;"><a href="#&#x201C;use-strict&#x201D;" class="headerlink" title="&#x201C;use strict&#x201D;"></a>&#x201C;use strict&#x201D;</h3><p>&#x5F00;&#x542F; ECMAScript 5 &#x5F15;&#x5165;&#x7684;&#x4E00;&#x6761;&#x547D;&#x4EE4;&#xFF0C;&#x5F00;&#x542F;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x3002;&#x8BF4;&#x660E;&#x540E;&#x7EED;&#x7684;&#x6240;&#x6709; JavaScript &#x4EE3;&#x7801;&#x90FD;&#x5728;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#x6267;&#x884C;&#x3002;</p>
<ul>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#x7981;&#x6B62;&#x4F7F;&#x7528; with &#x8BED;&#x53E5;</li>
<li>&#x5728;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x6240;&#x6709;&#x7684;&#x53D8;&#x91CF;&#x90FD;&#x8981;&#x5148;&#x58F0;&#x660E;&#xFF1B;</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;&#x8C03;&#x7528;&#x7684;&#x51FD;&#x6570;&#x4E2D;&#x7684;&#x4E00;&#x4E2A; this &#x503C;&#x662F; undefined &#xFF1B;<ul>
<li>&#x53EF;&#x4EE5;&#x5229;&#x7528;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x5224;&#x65AD; JavaScript &#x5B9E;&#x73B0;&#x662F;&#x5426;&#x652F;&#x6301;&#x4E25;&#x683C;&#x6A21;&#x5F0F;</li>
</ul>
</li>
</ul>
<figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">var</span> hasStrictMode = (<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>{</div><div class="line"><span class="meta">  &quot;use strict&quot;</span>;</div><div class="line">  <span class="keyword">return</span> <span class="keyword">this</span> === <span class="literal">undefined</span>;</div><div class="line">}());</div></pre></td></tr></table></figure>
<ul>
<li>&#x5728;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;&#x5F53;&#x901A;&#x8FC7; call() &#x6216; apply() &#x6765;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x65F6;&#xFF0C;&#x5176;&#x4E2D; this &#x503C;&#x5C31;&#x662F;&#x901A;&#x8FC7; call() &#x6216; apply() &#x4F20;&#x5165;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF1B;<br>+&#xFF08;&#x5728;&#x975E;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;null &#x548C; undefined &#x503C;&#x88AB;&#x5168;&#x5C40;&#x5BF9;&#x8C61;&#x548C;&#x8F6C;&#x6362;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;&#x8D39;&#x5BF9;&#x8C61;&#x503C;&#x6240;&#x66FF;&#x4EE3;&#xFF09;</li>
<li>&#x5728;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#xFF0C;&#x7ED9;&#x53EA;&#x8BFB;&#x5C5E;&#x6027;&#x548C;&#x7ED9;&#x4E0D;&#x53EF;&#x6269;&#x5C55;&#x7684;&#x5BF9;&#x8C61;&#x521B;&#x5EFA;&#x65B0;&#x6210;&#x5458;&#x90FD;&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x9519;&#x8BEF;&#x5F02;&#x5E38;&#x3002;<br>+&#xFF08;&#x5728;&#x975E;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E2D;&#xFF0C;&#x8FD9;&#x4E9B;&#x64CD;&#x4F5C;&#x53EA;&#x662F;&#x7B80;&#x5355;&#x5730;&#x64CD;&#x4F5C;&#x5931;&#x8D25;&#xFF0C;&#x4E0D;&#x4F1A;&#x62A5;&#x9519;&#xFF09;</li>
<li>&#x5728;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x4F20;&#x5165; eval() &#x7684;&#x4EE3;&#x7801;&#x4E0D;&#x80FD;&#x5728;&#x8C03;&#x7528;&#x7A0B;&#x5E8F;&#x9501;&#x5728;&#x7684;&#x4E0A;&#x4E0B;&#x6587;&#x4E2D;&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x6216;&#x5B9A;&#x4E49;&#x51FD;&#x6570;<ul>
<li>&#x5728;&#x975E;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E2D;&#x662F;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x505A;&#x7684;&#x3002;</li>
</ul>
</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x51FD;&#x6570;&#x91CC;&#x7684; arguments &#x5BF9;&#x8C61;&#x62E5;&#x6709;&#x4F20;&#x5165;&#x51FD;&#x6570;&#x503C;&#x7684;&#x9759;&#x6001;&#x526F;&#x672C;&#x3002;</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;delete &#x8FD0;&#x7B97;&#x7B26;&#x540E;&#x8DDF;&#x968F;&#x975E;&#x6CD5;&#x7684;&#x6807;&#x8BC6;&#x7B26;&#x4F1A;&#x629B;&#x51FA;&#x5F02;&#x5E38;</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x8BD5;&#x56FE;&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x4E0D;&#x53EF;&#x914D;&#x7F6E;&#x7684;&#x5C5E;&#x6027;&#x5C06;&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x9519;&#x8BEF;&#x5F02;&#x5E38;</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#xFF0C;&#x5728;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x76F4;&#x63A5;&#x91CF;&#x4E2D;&#x5B9A;&#x4E49;&#x4E24;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x540C;&#x540D;&#x5C5E;&#x6027;&#x5C06;&#x4F1A;&#x4EA7;&#x751F;&#x4E00;&#x4E2A;&#x8BED;&#x6CD5;&#x9519;&#x8BEF;</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#x662F;&#x4E0D;&#x5141;&#x8BB8;&#x4F7F;&#x7528;&#x516B;&#x8FDB;&#x5236;&#x6574;&#x6570;&#x76F4;&#x63A5;&#x91CF;</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E0B;&#x6807;&#x8BC6;&#x7B26; eval() &#x548C; arguments &#x5F53;&#x505A;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x5B83;&#x4EEC;&#x7684;&#x503C;&#x662F;&#x4E0D;&#x80FD;&#x66F4;&#x6539;&#x7684;&#x3002;&#x4E0D;&#x80FD;&#x7ED9;&#x8FD9;&#x4E9B;&#x6807;&#x8BC6;&#x7B26;&#x8D4B;&#x503C;&#x3002;</li>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x4E2D;&#x9650;&#x5236;&#x4E86;&#x5BF9;&#x8C03;&#x7528;&#x6808;&#x7684;&#x68C0;&#x6D4B;&#x80FD;&#x529B;&#xFF0C;&#x5728;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x7684;&#x51FD;&#x6570;&#x4E2D;&#xFF0C;arguments.caller &#x548C; arguments.callee &#x90FD;&#x4F1A;&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x9519;&#x8BEF;&#x5F02;&#x5E38;&#x3002;<ul>
<li>&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x7684;&#x51FD;&#x6570;&#x540C;&#x6837;&#x5177;&#x6709; caller &#x548C; arguments &#x5C5E;&#x6027;&#xFF0C;&#x5F53;&#x8BBF;&#x95EE;&#x8FD9;&#x4E24;&#x4E2A;&#x5C5E;&#x6027;&#x65F6;&#x5C06;&#x4F1A;&#x629B;&#x51FA;&#x7C7B;&#x578B;&#x9519;&#x8BEF;&#x5F02;&#x5E38;&#x3002;</li>
</ul>
</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>感谢您的支持！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>打 赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="http://ofy7k3v4s.bkt.clouddn.com/wcpayCode.jpg" alt="Hongqin Ma WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="http://ofy7k3v4s.bkt.clouddn.com/apayCode.jpg" alt="Hongqin Ma Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/js/" rel="tag">#js</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2014/04/06/06-js-Date、Math、包装对象、RegExp/" rel="next" title="js Date、Math、包装对象、RegExp">
                <i class="fa fa-chevron-left"></i> js Date、Math、包装对象、RegExp
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2014/05/02/07-js-的对象/" rel="prev" title="js 的对象">
                js 的对象 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <div class="ds-share flat" data-thread-key="2014/04/06/05-js-语句/"
     data-title="js语句"
     data-content=""
     data-url="https://hongqinma.github.io/2014/04/06/05-js-语句/">
  <div class="ds-share-inline">
    <ul  class="ds-share-icons-16">

      <li data-toggle="ds-share-icons-more"><a class="ds-more" href="javascript:void(0);">分享到：</a></li>
      <li><a class="ds-weibo" href="javascript:void(0);" data-service="weibo">微博</a></li>
      <li><a class="ds-qzone" href="javascript:void(0);" data-service="qzone">QQ空间</a></li>
      <li><a class="ds-qqt" href="javascript:void(0);" data-service="qqt">腾讯微博</a></li>
      <li><a class="ds-wechat" href="javascript:void(0);" data-service="wechat">微信</a></li>

    </ul>
    <div class="ds-share-icons-more">
    </div>
  </div>
</div>
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2014/04/06/05-js-语句/"
           data-title="js语句" data-url="https://hongqinma.github.io/2014/04/06/05-js-语句/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/photo.jpg"
               alt="Hongqin Ma" />
          <p class="site-author-name" itemprop="name">Hongqin Ma</p>
          <p class="site-description motion-element" itemprop="description">Spell at all costs， to rush you in the future. </p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">68</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">16</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">57</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/HongqinMa" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/HongqinMa" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/profile.php?id=100006581058735" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-facebook"></i>
                  
                  Facebook
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.zhihu.com/people/HirakuMa" target="_blank" title="知乎">
                  
                    <i class="fa fa-fw fa-share-alt"></i>
                  
                  知乎
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/rubylouvre/" title="司徒正美" target="_blank">司徒正美</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/sanshi/" title="三生石上" target="_blank">三生石上</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.cnblogs.com/TomXu/" title="汤姆大叔" target="_blank">汤姆大叔</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://gold.xitu.io/" title="掘金" target="_blank">掘金</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://segmentfault.com/" title="segmentfault" target="_blank">segmentfault</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.jianshu.com/users/1cbb94e5ed4d/latest_articles" title="简书" target="_blank">简书</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://home.cnblogs.com/" title="博客园" target="_blank">博客园</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.awesomes.cn/" title="Awesomes" target="_blank">Awesomes</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#条件判断结构-if-if…else-if…else-嵌套"><span class="nav-number">1.</span> <span class="nav-text">条件判断结构 if/ if…else/ if…else 嵌套</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Switch语句"><span class="nav-number">2.</span> <span class="nav-text">Switch语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#While循环语句"><span class="nav-number">3.</span> <span class="nav-text">While循环语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Do-while-语句"><span class="nav-number">4.</span> <span class="nav-text">Do while 语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#for循环"><span class="nav-number">5.</span> <span class="nav-text">for循环</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#break语句"><span class="nav-number">6.</span> <span class="nav-text">break语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#continue语句"><span class="nav-number">7.</span> <span class="nav-text">continue语句</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#break-和-continue-的区别"><span class="nav-number">7.1.</span> <span class="nav-text">break 和 continue 的区别</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#for-in-属性枚举语句"><span class="nav-number">8.</span> <span class="nav-text">for-in 属性枚举语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#label-（标签）语句"><span class="nav-number">9.</span> <span class="nav-text">label （标签）语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#with-语句"><span class="nav-number">10.</span> <span class="nav-text">with 语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#return-语句"><span class="nav-number">11.</span> <span class="nav-text">return 语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#throw-语句"><span class="nav-number">12.</span> <span class="nav-text">throw 语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#try-catch-finally-语句"><span class="nav-number">13.</span> <span class="nav-text">try/catch/finally 语句</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#其它语句"><span class="nav-number">14.</span> <span class="nav-text">其它语句</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#debugger-语句"><span class="nav-number">14.1.</span> <span class="nav-text">debugger 语句</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#“use-strict”"><span class="nav-number">14.2.</span> <span class="nav-text">“use strict”</span></a></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Hongqin Ma</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="https://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv">
    &nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Page Views: <span id="busuanzi_value_site_pv"></span> 
</span>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span>
  

  
    <span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span></span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"Hiraku"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/lib/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  <!-- custom analytics part create by xiamo -->
<script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
<script>AV.initialize("PPmoIQxeu8Sd21h6Tl9TthNx-gzGzoHsz", "rTvbY2H7DvWzRipiBwn72RQ4");</script>
<script>
function showTime(Counter) {
  var query = new AV.Query(Counter);
  $(".leancloud_visitors").each(function() {
    var url = $(this).attr("id").trim();
    query.equalTo("url", url);
    query.find({
      success: function(results) {
        if (results.length == 0) {
          var content = '0 ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
          return;
        }
        for (var i = 0; i < results.length; i++) {
          var object = results[i];
          var content = object.get('time') + ' ' + $(document.getElementById(url)).text();
          $(document.getElementById(url)).text(content);
        }
      },
      error: function(object, error) {
        console.log("Error: " + error.code + " " + error.message);
      }
    });

  });
}

function addCount(Counter) {
  var Counter = AV.Object.extend("Counter");
  url = $(".leancloud_visitors").attr('id').trim();
  title = $(".leancloud_visitors").attr('data-flag-title').trim();
  var query = new AV.Query(Counter);
  query.equalTo("url", url);
  query.find({
    success: function(results) {
      if (results.length > 0) {
        var counter = results[0];
        counter.fetchWhenSave(true);
        counter.increment("time");
        counter.save(null, {
          success: function(counter) {
            var content =  counter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(counter, error) {
            console.log('Failed to save Visitor num, with error message: ' + error.message);
          }
        });
      } else {
        var newcounter = new Counter();
        newcounter.set("title", title);
        newcounter.set("url", url);
        newcounter.set("time", 1);
        newcounter.save(null, {
          success: function(newcounter) {
              console.log("newcounter.get('time')="+newcounter.get('time'));
            var content = newcounter.get('time') + ' ' + $(document.getElementById(url)).text();
            $(document.getElementById(url)).text(content);
          },
          error: function(newcounter, error) {
            console.log('Failed to create');
          }
        });
      }
    },
    error: function(error) {
      console.log('Error:' + error.code + " " + error.message);
    }
  });
}
$(function() {
  var Counter = AV.Object.extend("Counter");
  if ($('.leancloud_visitors').length == 1) {
    addCount(Counter);
  } else if ($('.post-title-link').length > 1) {
    showTime(Counter);
  }
}); 
</script>

  
</body>
</html>
